package cn.edu.lit.jsjxy.CourseExample.chapter5;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import cn.edu.lit.jsjxy.CourseExample.R;

public class MusicPlayActivity extends Activity implements  OnClickListener
{
    Button startbtn, stopbtn;
    Context context;
    Intent intent;
    static TextView txt;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_music_play);

        startbtn = (Button) findViewById(R.id.butn1);
        stopbtn = (Button) findViewById(R.id.butn2);
        startbtn.setOnClickListener(this);
        stopbtn.setOnClickListener(this);
        txt = (TextView) findViewById(R.id.text1);

        intent = new Intent(MusicPlayActivity.this, AudioSrv.class);
    }

    @Override
    public void onClick(View view)
    {
        if (view.getId() == R.id.butn1)
        {
            startService(intent);
            txt.setText("start service .......");
        } else if (view.getId() == R.id.butn2)
        {
            stopService(intent);
        }
    }
}


